
/*************************
Data analysis GameChoice2 - February 2018
*****************************/

 
/*************
1) opening
*************/
clear
set more off
cap log close
*set mem 200m


/***************
2) open data
***************/
use "C:\Users\Astrid Dannenberg\Documents\Ada\Scott\Experiments\5. Experiment\Results\tests_data_stacked.dta", clear


/***************
3) Labeling and definitions
***************/

/*** Treatment labels ***/

label define treatment 1 "Unilateral-High", add
label define treatment 2 "Majority-High", add
label define treatment 3 "Multilateral-High", add
label define treatment 4 "Unilateral-Low", add
label define treatment 5 "Majority-Low", add
label define treatment 6 "Multilateral-Low", add
label values treatment treatment


/*** Definitions of variables ***/

gen treat1 = 0
replace treat1 = 1 if treatment==1
gen treat2 = 0
replace treat2 = 1 if treatment==2
gen treat3 = 0
replace treat3 = 1 if treatment==3
gen treat4 = 0
replace treat4 = 1 if treatment==4
gen treat5 = 0
replace treat5 = 1 if treatment==5
gen treat6 = 0
replace treat6 = 1 if treatment==6

gen r = v1_r1 if round==1
replace r = v1_r2 if round==2
replace r = v1_r3 if round==3
replace r = v1_r4 if round==4
replace r = v1_r5 if round==5
replace r = v2_r1 if round==6
replace r = v2_r2 if round==7
replace r = v2_r3 if round==8
replace r = v2_r4 if round==9
replace r = v2_r5 if round==10
replace r = v3_r1 if round==11
replace r = v3_r2 if round==12
replace r = v3_r3 if round==13
replace r = v3_r4 if round==14
replace r = v3_r5 if round==15
replace r = v4_r1 if round==16
replace r = v4_r2 if round==17
replace r = v4_r3 if round==18
replace r = v4_r4 if round==19
replace r = v4_r5 if round==20
replace r = v5_r1 if round==21
replace r = v5_r2 if round==22
replace r = v5_r3 if round==23
replace r = v5_r4 if round==24
replace r = v5_r5 if round==25

gen v1_r1_5 = (v1_r1+v1_r2+v1_r3+v1_r4+v1_r5)/5
gen v2_r1_5 = (v2_r1+v2_r2+v2_r3+v2_r4+v2_r5)/5
gen v3_r1_5 = (v3_r1+v3_r2+v3_r3+v3_r4+v3_r5)/5
gen v4_r1_5 = (v4_r1+v4_r2+v4_r3+v4_r4+v4_r5)/5
gen v5_r1_5 = (v5_r1+v5_r2+v5_r3+v5_r4+v5_r5)/5


by group round, sort: egen mean_v1_r1_5 = mean(v1_r1_5)
by group round, sort: egen mean_v2_r1_5 = mean(v2_r1_5)
by group round, sort: egen mean_v3_r1_5 = mean(v3_r1_5)
by group round, sort: egen mean_v4_r1_5 = mean(v4_r1_5)
by group round, sort: egen mean_v5_r1_5 = mean(v5_r1_5)

gen mean_r1_5 = mean_v1_r1_5 if round==1 | round==2 | round==3 | round==4 | round==5
replace mean_r1_5 = mean_v2_r1_5 if round==6 | round==7 | round==8 | round==9 | round==10
replace mean_r1_5 = mean_v3_r1_5 if round==11 | round==12 | round==13 | round==14 | round==15
replace mean_r1_5 = mean_v4_r1_5 if round==16 | round==17 | round==18 | round==19 | round==20
replace mean_r1_5 = mean_v5_r1_5 if round==21 | round==22 | round==23 | round==24 | round==25


gen v = v1 if round==1 | round==2 | round==3 | round==4 | round==5
replace v = v2 if round==6 | round==7 | round==8 | round==9 | round==10
replace v = v3 if round==11 | round==12 | round==13 | round==14 | round==15
replace v = v4 if round==16 | round==17 | round==18 | round==19 | round==20
replace v = v5 if round==21 | round==22 | round==23 | round==24 | round==25

by group round, sort: egen sum_v = sum(v)
replace sum_v = . if v==.
gen voted_B = 5 - sum_v

gen g = g1 if round==1 | round==2 | round==3 | round==4 | round==5
replace g = g2 if round==6 | round==7 | round==8 | round==9 | round==10
replace g = g3 if round==11 | round==12 | round==13 | round==14 | round==15
replace g = g4 if round==16 | round==17 | round==18 | round==19 | round==20
replace g = g5 if round==21 | round==22 | round==23 | round==24 | round==25


by group round, sort: egen mean_r = mean(r)
by group round, sort: egen sum_r = sum(r)

gen p = 2*sum_r + 5*(1-r) + 12 if g==1 & treatment<=3
replace p = 5*(sum_r-1) + 2 if g==0 & r==1 & treatment<=3
replace p = 17-sum_r if g==0 & r==0 & treatment<=3

replace p = 2*sum_r + 5*(1-r) + 4 if g==1 & treatment>3
replace p = 3*(sum_r-1) + 2 if g==0 & r==1 & treatment>3
replace p = sum_r + 9 if g==0 & r==0 & treatment>3

by group round, sort: egen mean_p = mean(p)


/***************
Regressions
***************/

/*** voting behavior ***/

gen others_average_v1_r1 = .
foreach group of num 1/120{
foreach subject of num 1/5{
sum v1_r1 if g1==1 & group==`group' & subject!=`subject'
gen m_`group'_no`subject' = r(mean)
replace others_average_v1_r1 = m_`group'_no`subject' if g1==1 & group==`group' & subject==`subject'
}
}
drop m_*

probit v2 i.v1_r1 others_average_v1_r1 if round==1 & treatment==1, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_v2.doc, replace

probit v2 i.v1_r1 others_average_v1_r1 if round==1 & treatment==2, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_v2.doc, append

probit v2 i.v1_r1 others_average_v1_r1 if round==1 & treatment==3, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_v2.doc, append

probit v2 i.v1_r1 others_average_v1_r1 if round==1 & treatment==4, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_v2.doc, append

probit v2 i.v1_r1 others_average_v1_r1 if round==1 & treatment==5, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_v2.doc, append

probit v2 i.v1_r1 others_average_v1_r1 if round==1 & treatment==6, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_v2.doc, append


/*** contribution behavior ***/

gen v_Bfirsttime = .
replace v_Bfirsttime = v2 if g2==0
replace v_Bfirsttime = v3 if g2==1 & g3==0
replace v_Bfirsttime = v4 if g2==1 & g3==1 & g4==0
replace v_Bfirsttime = v5 if g2==1 & g3==1 & g4==1 & g5==0

gen v_Afirsttime = .
replace v_Afirsttime = v2 if g2==1
replace v_Afirsttime = v3 if g2==0 & g3==1
replace v_Afirsttime = v4 if g2==0 & g3==0 & g4==1
replace v_Afirsttime = v5 if g2==0 & g3==0 & g4==0 & g5==1

by group round, sort: egen sum_v2 = sum(v2)
by group round, sort: egen sum_v3 = sum(v3)
by group round, sort: egen sum_v4 = sum(v4)
by group round, sort: egen sum_v5 = sum(v5)

gen sum_v_Bfirsttime = .
replace sum_v_Bfirsttime = sum_v2 if g2==0
replace sum_v_Bfirsttime = sum_v3 if g2==1 & g3==0
replace sum_v_Bfirsttime = sum_v4 if g2==1 & g3==1 & g4==0
replace sum_v_Bfirsttime = sum_v5 if g2==1 & g3==1 & g4==1 & g5==0

gen sum_v_Afirsttime = .
replace sum_v_Afirsttime = sum_v2 if g2==1
replace sum_v_Afirsttime = sum_v3 if g2==0 & g3==1
replace sum_v_Afirsttime = sum_v4 if g2==0 & g3==0 & g4==1
replace sum_v_Afirsttime = sum_v5 if g2==0 & g3==0 & g4==0 & g5==1

gen r_Bfirsttime = .
replace r_Bfirsttime = v2_r1 if g2==0
replace r_Bfirsttime = v3_r1 if g2==1 & g3==0
replace r_Bfirsttime = v4_r1 if g2==1 & g3==1 & g4==0
replace r_Bfirsttime = v5_r1 if g2==1 & g3==1 & g4==1 & g5==0

gen r_Afirsttime = .
replace r_Afirsttime = v2_r1 if g2==1
replace r_Afirsttime = v3_r1 if g2==0 & g3==1
replace r_Afirsttime = v4_r1 if g2==0 & g3==0 & g4==1
replace r_Afirsttime = v5_r1 if g2==0 & g3==0 & g4==0 & g5==1

probit r_Bfirsttime v_Bfirsttime sum_v_Bfirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==1, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, replace dec(3)
probit r_Bfirsttime v_Bfirsttime sum_v_Bfirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==2, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)
probit r_Bfirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==3, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)

probit r_Afirsttime v_Afirsttime sum_v_Afirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==1, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)
probit r_Afirsttime v_Afirsttime sum_v_Afirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==2, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)
probit r_Afirsttime v_Afirsttime sum_v_Afirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==3, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)

probit r_Bfirsttime v_Bfirsttime sum_v_Bfirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==4, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)
probit r_Bfirsttime v_Bfirsttime sum_v_Bfirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==5, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)
probit r_Bfirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==6, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)

probit r_Afirsttime v_Afirsttime sum_v_Afirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==4, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)
probit r_Afirsttime v_Afirsttime sum_v_Afirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==5, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)
probit r_Afirsttime v_Afirsttime sum_v_Afirsttime v1_r1 others_average_v1_r1 if round==1 & treatment==6, vce(cluster groups)
margins, dydx(*) atmeans post
outreg2 using probit_r.doc, append dec(3)


/***************
Panel regressions
***************/

/*** re-defining variables***/

gen vb = 0
replace vb = 1 if v==0
replace vb = . if v==.

gen gb = 0
replace gb = 1 if g==0


/*** Interaction dummies ***/

gen vbtreat1 = vb*treat1
gen vbtreat2 = vb*treat2
gen vbtreat3 = vb*treat3
gen vbtreat4 = vb*treat4
gen vbtreat5 = vb*treat5
gen vbtreat6 = vb*treat6

gen gbtreat1 = gb*treat1
gen gbtreat2 = gb*treat2
gen gbtreat3 = gb*treat3
gen gbtreat4 = gb*treat4
gen gbtreat5 = gb*treat5
gen gbtreat6 = gb*treat6

gen rtreat1 = r*treat1
gen rtreat2 = r*treat2
gen rtreat3 = r*treat3
gen rtreat4 = r*treat4
gen rtreat5 = r*treat5
gen rtreat6 = r*treat6

gen roundtreat1 = round*treat1
gen roundtreat2 = round*treat2
gen roundtreat3 = round*treat3
gen roundtreat4 = round*treat4
gen roundtreat5 = round*treat5
gen roundtreat6 = round*treat6


/*** Random effects panel regression ***/

xtset id round

/*** Baseline Unilateral ***/

xtreg p treat2 treat3 if treatment<=3, re cluster (id)
outreg2 using panel_re_p.doc, replace dec(3)
xtreg p vb gb r round treat2 treat3 if treatment<=3, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)
xtreg p gb round treat2 treat3 gbtreat2 gbtreat3 if treatment<=3, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)
xtreg p r round treat2 treat3 if treatment<=3 & g==1, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)
xtreg p r round treat2 treat3 rtreat2 rtreat3 roundtreat2 roundtreat3 if treatment<=3 & g==1, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)
xtreg p r round treat2 treat3 if treatment<=3 & g==0, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)
xtreg p r round treat2 treat3 rtreat2 rtreat3 roundtreat2 roundtreat3 if treatment<=3 & g==0, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)

xtreg p treat5 treat6 if treatment>3, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)
xtreg p vb gb r round treat5 treat6 if treatment>3, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)
xtreg p gb round treat5 treat6 gbtreat5 gbtreat6 if treatment>3, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)
xtreg p r round treat5 treat6 if treatment>3 & g==1, re cluster (id)
outreg2 using panel_re_P.doc, append dec(3)
xtreg p r round treat5 treat6 rtreat5 rtreat6 roundtreat5 roundtreat6 if treatment>3 & g==1, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)
xtreg p r round treat5 treat6 if treatment>3 & g==0, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)
xtreg p r round treat5 treat6 rtreat5 rtreat6 roundtreat5 roundtreat6 if treatment>3 & g==0, re cluster (id)
outreg2 using panel_re_p.doc, append dec(3)


/*** Baseline Majority ***/

xtreg p treat1 treat3 if treatment<=3, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, replace dec(3)
xtreg p vb gb r round treat1 treat3 if treatment<=3, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p gb round treat1 treat3 gbtreat1 gbtreat3 if treatment<=3, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p r round treat1 treat3 if treatment<=3 & g==1, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p r round treat1 treat3 rtreat1 rtreat3 roundtreat1 roundtreat3 if treatment<=3 & g==1, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p r round treat1 treat3 if treatment<=3 & g==0, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p r round treat1 treat3 rtreat1 rtreat3 roundtreat1 roundtreat3 if treatment<=3 & g==0, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)

xtreg p treat4 treat6 if treatment>3, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p vb gb r round treat4 treat6 if treatment>3, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p gb round treat4 treat6 gbtreat4 gbtreat6 if treatment>3, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p r round treat4 treat6 if treatment>3 & g==1, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p r round treat4 treat6 rtreat4 rtreat6 roundtreat4 roundtreat6 if treatment>3 & g==1, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p r round treat4 treat6 if treatment>3 & g==0, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)
xtreg p r round treat4 treat6 rtreat4 rtreat6 roundtreat4 roundtreat6 if treatment>3 & g==0, re cluster (id)
outreg2 using panel_re_p_basemaj.doc, append dec(3)


/*** Fixed effects panel regression ***/

/*** Baseline Unilateral ***/

xtreg p vb gb r round if treatment<=3, fe cluster (id)
outreg2 using panel_fe_p.doc, replace dec(3)
xtreg p gb round gbtreat2 gbtreat3 if treatment<=3, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)
xtreg p r round if treatment<=3 & g==1, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)
xtreg p r round rtreat2 rtreat3 roundtreat2 roundtreat3 if treatment<=3 & g==1, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)
xtreg p r round if treatment<=3 & g==0, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)
xtreg p r round rtreat2 rtreat3 roundtreat2 roundtreat3 if treatment<=3 & g==0, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)

xtreg p vb gb r round if treatment>3, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)
xtreg p gb round gbtreat5 gbtreat6 if treatment>3, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)
xtreg p r round if treatment>3 & g==1, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)
xtreg p r round rtreat5 rtreat6 roundtreat5 roundtreat6 if treatment>3 & g==1, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)
xtreg p r round if treatment>3 & g==0, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)
xtreg p r round rtreat5 rtreat6 roundtreat5 roundtreat6 if treatment>3 & g==0, fe cluster (id)
outreg2 using panel_fe_p.doc, append dec(3)


/*** Baseline Majority ***/

xtreg p vb gb r round if treatment<=3, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, replace dec(3)
xtreg p gb round gbtreat1 gbtreat3 if treatment<=3, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)
xtreg p r round if treatment<=3 & g==1, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)
xtreg p r round rtreat1 rtreat3 roundtreat1 roundtreat3 if treatment<=3 & g==1, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)
xtreg p r round if treatment<=3 & g==0, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)
xtreg p r round rtreat1 rtreat3 roundtreat1 roundtreat3 if treatment<=3 & g==0, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)

xtreg p vb gb r round if treatment>3, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)
xtreg p gb round gbtreat4 gbtreat6 if treatment>3, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)
xtreg p r round if treatment>3 & g==1, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)
xtreg p r round rtreat4 rtreat6 roundtreat4 roundtreat6 if treatment>3 & g==1, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)
xtreg p r round if treatment>3 & g==0, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)
xtreg p r round rtreat4 rtreat6 roundtreat4 roundtreat6 if treatment>3 & g==0, fe cluster (id)
outreg2 using panel_fe_p_basemaj.doc, append dec(3)



/***************
Graphs
***************/


/*** Contributions by group in Unilateral-High ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected sum_r round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==1 & subject==1, ytitle(Number of players) ylabel(#5) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = contributions in game A. Orange = contributions in game B)) by(, legend(off)) by(group)


/*** Payoffs by group in Unilateral-High ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected mean_p round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==1 & subject==1,  ytitle(Number of players) ylabel(#5) ylabel(#3, axis (2)) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = payoffs in game A. Orange = payoffs in game B)) by(, legend(off)) by(group)


/*** Contributions by group in Majority-High ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected sum_r round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==2 & subject==1, ytitle(Number of players) ylabel(#5) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = contributions in game A. Orange = contributions in game B)) by(, legend(off)) by(group)


/*** Payoffs by group in Majority-High ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected mean_p round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==2 & subject==1,  ytitle(Number of players) ylabel(#5) ylabel(#3, axis (2)) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = payoffs in game A. Orange = payoffs in game B)) by(, legend(off)) by(group)


/*** Contributions by group in Multilateral-High ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected sum_r round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==3 & subject==1, ytitle(Number of players) ylabel(#5) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = contributions in game A. Orange = contributions in game B)) by(, legend(off)) by(group)


/*** Payoffs by group in Multilateral-High ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected mean_p round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==3 & subject==1,  ytitle(Number of players) ylabel(#5) ylabel(#3, axis (2)) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = payoffs in game A. Orange = payoffs in game B)) by(, legend(off)) by(group)


/*** Contributions by group in Unilateral-Low ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected sum_r round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==4 & subject==1, ytitle(Number of players) ylabel(#5) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = contributions in game A. Orange = contributions in game B)) by(, legend(off)) by(group)


/*** Payoffs by group in Unilateral-Low ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected mean_p round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==4 & subject==1,  ytitle(Number of players) ylabel(#5) ylabel(#3, axis (2)) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = payoffs in game A. Orange = payoffs in game B)) by(, legend(off)) by(group)


/*** Contributions by group in Majority-Low ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected sum_r round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==5 & subject==1, ytitle(Number of players) ylabel(#5) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = contributions in game A. Orange = contributions in game B)) by(, legend(off)) by(group)


/*** Payoffs by group in Majority-Low ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected mean_p round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==5 & subject==1,  ytitle(Number of players) ylabel(#5) ylabel(#3, axis (2)) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = payoffs in game A. Orange = payoffs in game B)) by(, legend(off)) by(group)


/*** Contributions by group in Multilateral-Low ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected sum_r round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(blue) lcolor(blue)) ///
(connected sum_r round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), sort mcolor(dkorange) lcolor(dkorange)) ///
(connected sum_r round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==6 & subject==1, ytitle(Number of players) ylabel(#5) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = contributions in game A. Orange = contributions in game B)) by(, legend(off)) by(group)


/*** Payoffs by group in Multilateral-Low ***/

twoway (bar voted_B round, fcolor(olive_teal) lcolor(olive_teal)) ///
(connected mean_p round if g==1 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==1 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(blue) lcolor(blue)) ///
(connected mean_p round if g==0 & (round==1 | round==2 | round==3 | round==4 | round==5), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==6 | round==7 | round==8 | round==9 | round==10), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==11 | round==12 | round==13 | round==14 | round==15), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==16 | round==17 | round==18 | round==19 | round==20), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
(connected mean_p round if g==0 & (round==21 | round==22 | round==23 | round==24 | round==25), yaxis(2) sort mcolor(dkorange) lcolor(dkorange)) ///
if treatment==6 & subject==1,  ytitle(Number of players) ylabel(#5) ylabel(#3, axis (2)) xtitle(Round) xlabel(minmax) xlabel(#5) ///
by(, caption(Bars show the number of players who voted for game B., size(small)) ///
note(Blue = payoffs in game A. Orange = payoffs in game B)) by(, legend(off)) by(group)

